﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Entities;
using Sales.Business.BO;

namespace Sales.Web.Controllers
{
    public class FoodController : Controller
    {
        private FoodBO FoodBO = new FoodBO();

        //
        // GET: /Staff/

        public ActionResult Index()
        {
            return View(FoodBO.GetAll());
        }

        //
        // GET: /Staff/Details/5

        public ActionResult Details(int id = 0)
        {
            Food_Beverage food = FoodBO.GetItemByID(id);
            if (food == null)
            {
                return HttpNotFound();
            }
            return View(food);
        }

        //
        // GET: /Staff/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Staff/Create

        [HttpPost]
        public ActionResult Create(Food_Beverage food)
        {
            if (ModelState.IsValid)
            {
                FoodBO.Add(food);
                return RedirectToAction("Index");
            }

            return View(food);
        }

        //
        // GET: /Staff/Edit/5

        public ActionResult Edit(int id = 0)
        {
            Food_Beverage food = FoodBO.GetItemByID(id);
            if (food == null)
            {
                return HttpNotFound();
            }
            return View(food);
        }

        //
        // POST: /Staff/Edit/5

        [HttpPost]
        public ActionResult Edit(Food_Beverage food)
        {
            if (ModelState.IsValid)
            {
                FoodBO.Update(food.FID, food);
                return RedirectToAction("Index");
            }
            return View(food);
        }

        public ActionResult Delete(int id)
        {
            FoodBO.Remove(id);
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }
    }
}